package com.example.demo.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;

/**
 * 仓库实体
 */
@Data
@Entity
@Table(name = "warehouses")
@EqualsAndHashCode(callSuper = true)
public class Warehouse extends BaseEntity {
    
    @Column(name = "warehouse_code", unique = true, nullable = false, length = 50)
    private String warehouseCode;
    
    @Column(name = "warehouse_name", nullable = false, length = 100)
    private String warehouseName;
    
    @Column(name = "description", length = 200)
    private String description;
    
    @Column(name = "address", length = 200)
    private String address;
    
    @Column(name = "contact_person", length = 50)
    private String contactPerson;
    
    @Column(name = "contact_phone", length = 20)
    private String contactPhone;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false)
    private WarehouseStatus status = WarehouseStatus.ACTIVE;
    
    @Column(name = "capacity")
    private Integer capacity;
    
    @Column(name = "current_usage")
    private Integer currentUsage = 0;
    
    /**
     * 仓库状态枚举
     */
    public enum WarehouseStatus {
        ACTIVE("启用"),
        INACTIVE("停用"),
        MAINTENANCE("维护中");
        
        private final String description;
        
        WarehouseStatus(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
}
